
 const inquirer=require('inquirer');
const utils=require('./utils');
 const prompList=[
     {
         type:'list',
         message:'选择操作类型',
         choices:['添加','查询','删除','查看'],
         name:'filetype'

     }
 ]

exports.actionHandle=async (options)=>{
    
    const {filetype}=await inquirer.prompt(prompList);
   
    switch (filetype){
        case '添加':
            inquirer.prompt([
                {
                    type:'input',
                    message:'输入文件名',
                    name:'filename',

                }
            ]).then(({filename})=>{
               utils.addFile(filename)
            })
            break;

        case '删除':
            inquirer.prompt({
                type:'list',
                message:'要删除的文件',
                name:'filename',
                choices:[...utils.getfile()]
            }).then(({filename})=>{
                utils.delfile(filename)
            })

            break;
    }
}
